API Documentation
Public Member Functions | List of all members
nkResources::ResourceManager Class Referencefinal

Manager helping with path finding and resource loading. More...

Inheritance diagram for nkResources::ResourceManager:

Public Member Functions

void setWorkingPath (const std::string_view &path)
 
void setWorkingPathAbsolute (const std::string_view &path)
 
const char * getWorkingPath () const
 
const char * getWorkingPathAbsolute () const
 
const char * getLaunchedPath () const
 
void setLaunchedPath (const std::string_view &path)
 
std::string getRelativeFromAbsolute (const std::string_view &absolutePath) const
 
std::string getAbsoluteFromRelative (const std::string_view &relativePath) const
 
std::string getRelativeFromWorkingDir (const std::string_view &workingPath) const
 
std::string getAbsoluteFromWorkingDir (const std::string_view &workingPath) const
 
std::string getFromWorkingDirFromRelative (const std::string_view &relativePath) const
 
std::string getFromWorkingDirFromAbsolute (const std::string_view &absolutePath) const
 
bool checkFileExists (const std::string_view &filePathAbs) const
 
void checkFolderExists (const char *path)
 
nkMemory::Buffer loadFileIntoMemory (const std::string_view &filePathAbs, bool silent=false)
 

Detailed Description

Manager helping with path finding and resource loading.

It uses 3 keywords for all paths it manipulates :

Transformations from one path to another use these keywords :

Member Function Documentation

◆ setWorkingPath()

void nkResources::ResourceManager::setWorkingPath ( const std::string_view &  path)

Sets the working path.

Parameters
pathThe path of the wanted path, relative to the path from where the software is launched.

◆ setWorkingPathAbsolute()

void nkResources::ResourceManager::setWorkingPathAbsolute ( const std::string_view &  path)

Sets the working path.

Parameters
pathThe path of the wanted path, absolute.

◆ getWorkingPath()

const char* nkResources::ResourceManager::getWorkingPath ( ) const
Returns
The current set working path, as a path relative to the path from where the software is launched.

◆ getWorkingPathAbsolute()

const char* nkResources::ResourceManager::getWorkingPathAbsolute ( ) const
Returns
The current set working path, absolute.

◆ getLaunchedPath()

const char* nkResources::ResourceManager::getLaunchedPath ( ) const
Returns
The path from where the program was launched.

◆ setLaunchedPath()

void nkResources::ResourceManager::setLaunchedPath ( const std::string_view &  path)

Allows to override the path from which the program is launched.

Remarks
This path is already populated by default by the ResourceManager. Call this function only if you really need to.

◆ getRelativeFromAbsolute()

std::string nkResources::ResourceManager::getRelativeFromAbsolute ( const std::string_view &  absolutePath) const

Converts a path, from absolute, to a path relative to the launched path.

Parameters
absolutePathThe absolute path to convert.
Returns
The path converted.

◆ getAbsoluteFromRelative()

std::string nkResources::ResourceManager::getAbsoluteFromRelative ( const std::string_view &  relativePath) const

Converts a path, from relative to the launched directory, to absolute.

Parameters
relativePathThe relative path to convert.
Returns
The path converted.

◆ getRelativeFromWorkingDir()

std::string nkResources::ResourceManager::getRelativeFromWorkingDir ( const std::string_view &  workingPath) const

Converts a path, from relative to the working directory, to relative to the launched path.

Parameters
workingPathThe path relative to the working directoy to convert.
Returns
The path converted.

◆ getAbsoluteFromWorkingDir()

std::string nkResources::ResourceManager::getAbsoluteFromWorkingDir ( const std::string_view &  workingPath) const

Converts a path, from relative to the working directory, to absolute.

Parameters
workingPathThe path relative to the working directoy to convert.
Returns
The path converted.

◆ getFromWorkingDirFromRelative()

std::string nkResources::ResourceManager::getFromWorkingDirFromRelative ( const std::string_view &  relativePath) const

Converts a path, from relative to the launched directory, to relative to the working directory.

Parameters
relativePathThe path relative to the launched path to convert.
Returns
The path converted.

◆ getFromWorkingDirFromAbsolute()

std::string nkResources::ResourceManager::getFromWorkingDirFromAbsolute ( const std::string_view &  absolutePath) const

Converts a path, from absolute, to relative to the working directory.

Parameters
absolutePathThe absolute path to convert.
Returns
The path converted.

◆ checkFileExists()

bool nkResources::ResourceManager::checkFileExists ( const std::string_view &  filePathAbs) const

Checks if a file exists for a certain path.

Parameters
filePathAbsThe absolute path to check.
Returns
True if the file exists, false otherwise.

◆ checkFolderExists()

void nkResources::ResourceManager::checkFolderExists ( const char *  path)

Checks if a folder exists for a certain path.

Parameters
pathThe absolute path to check.
Returns
True if the file exists, false otherwise.

◆ loadFileIntoMemory()

nkMemory::Buffer nkResources::ResourceManager::loadFileIntoMemory ( const std::string_view &  filePathAbs,
bool  silent = false 
)

Loads a file into memory.

Parameters
filePathAbsThe path to the file, absolute.
silentIf a failure in finding the requested file should not be logged. True for no logging, false otherwise.
Returns
A binary buffer holding the file data.

The documentation for this class was generated from the following file: